package com.qdu.average;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class AverageMapper extends Mapper<LongWritable, Text,Text,LongWritable> {
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException {
        String line=value.toString();
        if (line.contains("id")){
            return;
        }
        String[] data=line.split(",");
        Long time=Long.parseLong(data[8]);
        if (data.length<8||time==0) {
            return;
        }
        context.write(new Text(data[1]),new LongWritable(time));
    }
}
